package cn.itcast.hotel.controller;


import cn.itcast.hotel.pojo.PageResult;
import cn.itcast.hotel.pojo.RequestParams;
import cn.itcast.hotel.service.IHotelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/hotel")
public class HotelController {
    //注入service
    @Autowired
    private IHotelService iHotelService;

    //搜索酒店数据
    @PostMapping("/list")
    public PageResult search(@RequestBody RequestParams requestParams) throws IOException {
        return  iHotelService.search(requestParams);
    }

    //通过聚合索引库中得到酒店数据
    @PostMapping("/filters")
    public Map<String, List<String>> getFilters(@RequestBody RequestParams params) throws IOException {
        return iHotelService.getFilters(params);
    }


    @GetMapping("/suggestion")
    public List<String> suggestion(@RequestParam("key") String key){
        return iHotelService.suggetions(key);
    }
}
